<?php
namespace App\Http\Controllers\Web;

use App\Models\Members;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Library\UploadFile;

class UserController extends Controller{
	public $result = array("status"=>0,'msg'=>'请求成功','data'=>[]);
	
	/**
	 * 前端修改密码
	 * 
	 */
	public function passupdate($id,$pass){
		$user = Members::find((int)$id);
		
     	if (isset($pass) && $pass != '') {
            $user->password = bcrypt($pass);
        }
        $bool=$user->save();
        if($bool){
        	return response()->json($this->result);
        }else{
        	$this->result['status'] = 1;
        	return response()->json($this->result);
        }
	}
	
	/**
	 * 前端修改头像
	 * 
	 */
	public function picurl(Request $request,$id){
		$data['pic'] = $request->pic;
		$bool = Members::where('id','=',(int)$id)->update($data);
		if($bool){
			return response()->json($this->result);
		}else{
			$this->result['status'] = 1;
			return response()->json($this->result);
		}
	}
}
